﻿using System.Globalization;
using System.Windows.Data;

namespace CoreModule.Converters
{
    /// <summary>
    /// 没有设备值 转换成字符串
    /// </summary>
    public class NotDeviceIntValueToStringConverter : IValueConverter
    {

        /// <summary>
        /// 
        /// </summary>
        public string Placeholder { get; set; } = "-";

        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {

            var f = (int)value;

            ///这个固定值
            if (f==CoreConstant.NotDevice)
            {
                return Placeholder;
            }
            else
            {
                return f.ToString();
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
